import {createStore, applyMiddleware, compose} from "redux";
//引入笔记本
import reducer from "./reducer";
import thunk from "redux-thunk";

const composeEnhancers =
    window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ?
        window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({}) : compose;
const enhancer = composeEnhancers(
    applyMiddleware(thunk),
    // other store enhancers if any
);
/**
 * 创建数据的公共存储仓库
 * 相当于图书馆的管理员，还需要Reducers辅助
 * 使用reducer构建初始的数据，然后在创建store的时候会使用一个叫做thunk的中间件
 * @type {Store<S, Action> & Store<S, A> & {dispatch: ThunkDispatch<any, undefined, AnyAction>}}
 */
const store = createStore(reducer, enhancer);
export default store;